﻿@using Vote.Models;
@{
    ViewBag.Title = "Votes";
    Layout = null;
    var Model = ViewBag.Model;
    var PlaceHolder = ViewBag.PlaceHolder;
}
<link href="@Url.Content("~/Content/common.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/demos.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/jquery-weui.min.css")" rel="stylesheet" type="text/css" />
<!DOCTYPE html>
<html>
<head>
    <title>投票</title>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <style>
        body {
            background: url("@Url.Content("~/images/liu-bg_01.png")") no-repeat;
            background-size: cover;
        }
    </style>
</head>
<script src="@Url.Content("~/Scripts/jquery-1.9.1.min.js")"></script>
<body>
    <!--头部开始-->
    <div class="header">
        <div class="header-bottom-left fl">
            <a href="#"><img class="bottom-icon" src="@Url.Content("~/images/left-bottom.png")"><span class=" return-text">返回</span></a>
        </div>
        <div class="header-title fl">
            <h3>投票</h3>
        </div>
        <div class="header-title-right fr">
            <a href="#"><h3 style="font-size: 1.8rem;color: #fff;margin-top: -0.5rem;">...</h3></a>
        </div>
    </div>
    <!--轮播-->
    <div class="swiper-box">
        <div class="swiper-container">
            <!-- Additional required wrapper -->
            <div class="swiper-wrapper">
                <!-- Slides -->
                <div class="swiper-slide"><img src="@Url.Content("~/images/swiper-1.jpg")" /></div>
                <div class="swiper-slide"><img src="@Url.Content("~/images/swiper-2.jpg")" /></div>
                <div class="swiper-slide"><img src="@Url.Content("~/images/swiper-3.jpg")" /></div>
            </div>
            <!-- If we need pagination -->
            <div class="swiper-pagination"></div>
        </div>
    </div>
    <!--导航-->
    <ul class="nav-box">
        <li><a href="@Url.Action("Votes", "Test", new { VoteNumberId ='0' })">全部</a></li>
        <li><a href="@Url.Action("Votes", "Test", new { VoteNumberId = '1' })">第一场</a></li>
        <li><a href="@Url.Action("Votes", "Test", new { VoteNumberId = '2' })">第二场</a></li>
        <li><a href="@Url.Action("Votes", "Test", new { VoteNumberId = '3' })">第三场</a></li>
    </ul>
    <!--搜索-->
    @if (PlaceHolder != null && PlaceHolder != "")
    {
        <div class="search-box">
            <input class="search-tip fl" id="FestivalName" type="text" onkeydown="serkeydown(this,event)" placeholder=@PlaceHolder>
            <input type="button" class="search-btn fr" onclick="return submitSearch();" value="搜索">
        </div>
    }
    else
    {
        <div class="search-box">
            <input class="search-tip fl" id="FestivalName" type="text" onkeydown="serkeydown(this,event)" placeholder="请输入节目编号或名称">
            <input type="button" class="search-btn fr" onclick="return submitSearch();" value="搜索">
        </div>
    }
    <!--搜索滚动-->
    <div class="search-box" id="logo">
        <input class="search-tip fl" type="text" placeholder="请输入节目编号或名称">
        <input type="button" class="search-btn fr" value="搜索">
    </div>
    <!--搜索滚动-->
    <div class="footer-top">
        <img src="@Url.Content("~/images/footer-top.png")">
    </div>
    <script>
      /* 回到顶部 */
      $(function () {
          $(function () {
              $(window).scroll(function () {
                  /* 判断滚动条 距离页面顶部的距离 100可以自定义*/
                  if ($(window).scrollTop() > 600) {
                      $(".footer-top").fadeIn(200); /* 这里用.show()也可以 只是效果太丑 */
                  } else {
                      $(".footer-top").fadeOut(200);
                  }
              });
          });
          /* 给图片元素绑定 回到顶部的事件 */
          $(function () {
              $(".footer-top").on("click", function () {
                  $('body,html').animate({
                      scrollTop: 0
                  }, 500);
                  return false;
              });
          });
      });

      function confirmHtml(text) {
          var html = '<div class="weui-dialog weui-dialog--visible" id="confirm">'
                 + '<div class="weui-dialog__hd">'
                 + '   <strong class="weui-dialog__title">'
                 + '       <img src="@Url.Content("~/images/sf.png")">'
                 + text
                 + '  </strong>'
                 + ' </div><div class="weui-dialog__bd"></div>'
                 + ' <div class="weui-dialog__ft">'
                 + '     <a onclick="CancelConfirm()" class="weui-dialog__btn primary">确定</a>'
                 + ' </div>'
                 + ' </div>';
          $('body').append(html);
          $(".weui-mask,.weui-dialog").show();

      }
        function CancelConfirm() {
            $(".weui-mask--visible").hide();
            $("#confirm").remove();
        }
    </script>
    <!--player选手列表-->
    @*@RenderPage("~/Views/Test/TestPlayer.cshtml", ViewBag.Model)*@

    @{Html.RenderAction("TestPlayer", "Test", new { VoteNumberId=-1 });}

    <div class="weui-mask weui-mask--visible"></div>

    <!--footer菜单-->
    <ul class="footer-menu">
        <li><a href="#">参赛节目</a></li>
        <li><a href="#">赛事规则</a></li>
        <li><a href="http://m.gxanr.com">爱农人商城</a></li>
    </ul>


    <script src="@Url.Content("~/Scripts/jquery-1.9.1.min.js")"></script>
    <script src="@Url.Content("~/Scripts/fastclick.js")"></script>
    <script src="@Url.Content("~/Scripts/jquery.lazyload.js")"></script>
    <script>
  $(function() {
      FastClick.attach(document.body);
  });
    </script>
    <script src="@Url.Content("~/Scripts/jquery-weui.min.js")"></script>
    <script src="@Url.Content("~/Scripts/swiper.min.js")"></script>
    <script>
      $(".swiper-container").swiper({
        loop: true,
        autoplay: 3000
      });
    </script>
    <script>
    var loading = false;
    var html = '';
    @*function GetHtml(){
        html = '<li>'
    + '<div class="player-list fl">'
    + '<div class="p-img-box">'
    + '<img class="list-p-icon" src="'+'@Model[@i].ImgUrl'+'">'
    + '<div class="r-p-text">'
    + '<img class="p-num" src="/images/p-number.png">'
    + '<span class="p-num-text">999</span>'
    + '</div>'
    + '</div>'
    + '<div class="p-text-box">'
    + '<div class="p-text p-text-text fl">'
    + '<h4>可怜没人爱</h4>'
    + '<span>票数：</span><span>999999</span>'
    + '</div>'
    + '<div class="p-text fr">'
    + '<a href="#">投票</a>'
    + '</div>'
    + '</div>'
    + '</div>'
    + '</li>';
        return html;
    }
    $(document.body).infinite().on("infinite", function() {
        if(loading) return;
        loading = true;
        setTimeout(function () {
            html =GetHtml();
            $("#list").append(html+html);
            toupiao()
            loading = false;
        }, 1000);
    });*@
    </script>
    <!--弹框-->
    <script>
      $(document).ready(function(){
          toupiao();
          //懒加载
      })
      //懒加载
      $(function () {
          $("img.lazy").lazyload({ effect: "fadeIn" });
      });
      function toupiao(){
          $(".weui-dialog__btn").click(function(){
              $(".weui-mask,.weui-dialog").hide();
          })
          $(".p-text a").click(function () {
              var showIds = $(this).attr("id");
              var ancestors = $(this).parent().parent().parent();
              $.ajax({
                  type: "post",
                  url: '@Url.Action("VoteByUser","Home")',
                  data: { showId: showIds },
                  async: false,
                  success: function (result) {
                      if (result == "0") {
                          confirmHtml("今天已经投过了这个节目");
                      }
                      else if (result == "2") {
                         
                          //投票已经用完
                          confirmHtml("这个场次的投票已经用完");
                      }
                      else {
                          //投票成功
                          $(this).html("已投");
                          ancestors.find("#" + showIds + "-head").text(result);
                          ancestors.find("#" + showIds + "-bottom").text(result);
                          confirmHtml("投票成功");
                      }
                  }
              });
          })
      }
        //搜索
      function submitSearch() {
          var FestName = document.getElementById("FestivalName").value;
          if (FestName != null) {
              window.location.href = encodeURI('/Home/SearchFestival' + '?FestName=' + FestName);
          }
          else {
              alert("请输入搜索内容！");
          }
      }
    </script>
</body>
</html>
